import { Controller, Get, Body,Put ,UseGuards,Param,Query} from '@nestjs/common';
import { ErrbookService } from './errbook.service';
import { AuthGuard } from '../../guards/auth.guard';
import { User, userType } from "../user.decorators";


@Controller('user-errbook')
export class ErrbookController {
  constructor(private readonly ErrbookService: ErrbookService) {}
  @Get('')
  @UseGuards(AuthGuard)
  getCourseList(@User() user:userType,
   @Query() query: { page: string; size: string,key:string }) {
  const page = parseInt(query.page, 10);
  const size = parseInt(query.size, 10);
  return this.ErrbookService.getErrBookList(user.userId, query.key,page, size);
  }
  @Put('')
  @UseGuards(AuthGuard)
  submitErrBook(@User() user:userType,@Body() body:string[]) {
    return this.ErrbookService.submitErrBook(user.userId,body);
  }
}